package com.yyj.schedule;

import com.yyj.service.PaymentService;
import com.yyj.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时生成每月业主费用账单，每个月第一天生成
 */
@Component
@EnableScheduling
public class PaymentSchedule {

    public static Logger log = LoggerFactory.getLogger(PaymentSchedule.class);

    @Autowired
    private PaymentService paymentService;

    /**
     *  处理管卫费
     */
    @Scheduled(cron = "0 0 1 1 * ?")
    private void initManagePayment(){
        try{
            log.info("initManagePayment>>>>>>"  , DateUtil.getNowLongTime());
            paymentService.initManagePayment();

        }catch(Exception e){
            log.error("initManagePayment" , e.getMessage() , e);
        }

    }

    /**
     *  处理物业费
     */
//    @Scheduled(cron = "0 10 1 1 * ?")
//    private void handlePropertyPayment(){
//        try{
//            log.info("handlePropertyPayment>>>>>>"  , DateUtil.getNowLongTime());
//            paymentService.initPropertyPayment();
//
//        }catch(Exception e){
//            log.error("handlePropertyPayment" , e.getMessage() , e);
//        }
//
//    }

    public static void main(String[] args) {
        try {
            new PaymentService().initPropertyPayment();
            new PaymentService().initSanitaryPayment();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
